﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace BSU.GraduateWork.Web.Binders
{
    public abstract class BaseModelBinder:IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            return Bind(controllerContext, bindingContext);
        }

        public abstract object Bind(ControllerContext controllerContext, ModelBindingContext bindingContext);

        protected static int ParseParamAsInt(string param)
        {
            int value;
            Int32.TryParse(param, out value);
            return value;
        }

        protected static double ParseParamAsDouble(string param)
        {
            double value;
            Double.TryParse(param, out value);
            return value;
        }
    }
}
